{% extends "ipr/search_result.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters static %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block search_header %}Search result on "{{ q }}"{% endblock %}
{% block search_result %}
    {% if not docs %}
        <p class="alert alert-success my-3">
            No IPR disclosures related to a document with the words "{{ q }}"" in the title have been submitted.
        </p>
    {% else %}
        <p class="alert alert-info my-3">
            Total number of IPR disclosures found: <b>{{ iprs|length }}</b>.
        </p>
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col" data-sort="date">Date</th>
                    <th scope="col" data-sort="id">ID</th>
                    <th scope="col" data-sort="statement">Statement</th>
                </tr>
            </thead>
            {% for doc in docs %}
                <tbody>
                    <tr>
                        <th scope="col" class="table-info" colspan="3">
                            IPR that is related to {{ doc.name|prettystdname:""|urlize_ietf_docs }} ("{{ doc.title }}")
                            {% if doc.related %}
                                that was {{ doc.relation|lower }} {{ doc.related.source.name|prettystdname:""|urlize_ietf_docs  }} ("{{ doc.related.source.title }}")
                            {% endif %}
                        </th>
                    </tr>
                </tbody>
                <tbody>
                    {% if doc.ipr %}
                        {% for ipr in doc.ipr %}
                            <tr>
                                <td>{{ ipr.disclosure.time|date:"Y-m-d" }}</td>
                                <td>{{ ipr.disclosure.id }}</td>
                                <td>
                                    {% for item in ipr.disclosure.updated_by.all %}
                                        {% if item.source.state_id == "posted" %}
                                            IPR disclosure #{{ item.source.id }}:
                                            <a href="{% url "ietf.ipr.views.show" item.source.id %}">{{ item.source.title }}</a>
                                            <br>
                                            Updates:
                                        {% endif %}
                                    {% endfor %}
                                    <a href="{% url "ietf.ipr.views.show" ipr.disclosure.id %}">{{ ipr.disclosure.title }}</a>
                                </td>
                            </tr>
                        {% endfor %}
                    {% else %}
                        <tr>
                            <td></td>
                            <td></td>
                            <td>No IPR disclosures related to {{ doc.name|prettystdname|urlize_ietf_docs }} have been submitted.</td>
                        </tr>
                    {% endif %}
                </tbody>
            {% endfor %}
        </table>
    {% endif %}
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}